﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RobotJog.ITxRoboticLocationOperationEx
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections.Generic;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.RobotJog;

internal static class ITxRoboticLocationOperationEx
{
  public static void Teach(this ITxRoboticLocationOperation location)
  {
    if (location == null)
      return;
    ITxRoboticLocationOperationEx.TeachPosition(location);
    location.TeachCurrentRobotConfiguration();
  }

  public static void Teach(
    this ITxRoboticLocationOperation location,
    TxTransformation position,
    TxRobotConfigurationData configData)
  {
    if (TxTransformation.op_Inequality(position, (TxTransformation) null))
    {
      TxRoboticTransformationParam transformationParam = new TxRoboticTransformationParam("POSITION_IN_SIMULATION", position);
      ((ITxRoboticOperation) location).SetParameter((TxRoboticParam) transformationParam);
    }
    else if (((ITxRoboticOperation) location).GetParameter("POSITION_IN_SIMULATION") is TxRoboticTransformationParam)
      ((ITxRoboticOperation) location).RemoveParameter("POSITION_IN_SIMULATION");
    location.RobotConfigurationData = configData;
    TxRobot operationAssignedRobot = CApRJRobotJogUtilities.GetRoboticLocationOperationAssignedRobot((ITxObject) location) as TxRobot;
    if (!TxRobot.op_Inequality(operationAssignedRobot, (ITxObject) null) || !operationAssignedRobot.IsSingularityConfigured() || operationAssignedRobot.UsesNumericInverse)
      return;
    ITxRoboticLocationOperationEx.SetTaughtPose(location, (TxPoseData) null);
  }

  public static TxTransformation GetTaughtPosition(this ITxRoboticLocationOperation location)
  {
    TxTransformation taughtPosition = (TxTransformation) null;
    if (((ITxRoboticOperation) location).GetParameter("POSITION_IN_SIMULATION") is TxRoboticTransformationParam parameter)
      taughtPosition = parameter.Value;
    return taughtPosition;
  }

  public static bool IsDifferent<T>(this IEnumerable<T> source, IEnumerable<T> target)
  {
    if (source == target)
      return false;
    return source == null || target == null || !new HashSet<T>(target).SetEquals(source);
  }
}
